package org.apache.doris.flink.rest.models;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
 * ClassName: BackendV2
 * Package: org.apache.doris.flink.rest.models
 * Description:
 *
 * @author CYoung
 * @version 1.0
 * @create 2023/9/8 16:40
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class BackendV2 {

    @JsonProperty(value = "backends")
    private List<BackendRowV2> backends;

    public List<BackendRowV2> getBackends() {
        return backends;
    }

    public void setBackends(List<BackendRowV2> backends) {
        this.backends = backends;
    }

    public static class BackendRowV2 {
        public String ip;
        public int http_port;
        public boolean is_alive;

        public String getIp() {
            return ip;
        }

        public void setIp(String ip) {
            this.ip = ip;
        }

        public int getHttpPort() {
            return http_port;
        }

        public void setHttpPort(int httpPort) {
            this.http_port = httpPort;
        }

        public boolean isAlive() {
            return is_alive;
        }

        public void setAlive(boolean alive) {
            is_alive = alive;
        }

        public String toBackendString() {
            String res = null;
            switch (ip) {
                // hadoop104 内网地址
                case "172.21.0.16":
                    res = "localhost:8040";
                    break;
                // hadoop105 内网地址
                case "172.21.0.2":
                    res = "localhost:8041";
                    break;
                // hadoop106 内网地址
                case "172.21.0.8":
                    res = "localhost:8042";
                    break;
//                case "172.21.0.6":
//                    res = "hadoop102";
//                    break;
//                case "172.21.0.2":
//                    res = "hadoop103";
//                    break;
            }
            return res;
        }

    }
}
